//继承模板
{extend name="public/base"}


//CSS
{block name="style"}
<link rel="stylesheet" href="__ADMIN_STATIC__/lib/zTree/v3/css/zTreeStyle/zTreeStyle.css" type="text/css">
{/block}


{block name="breadcrumb" title="当前位置"}{/block}

//正文区域
{block name="body"}{//---------------------------------------------------------------------------}
<div class="page-container">

<div class="form form-horizontal">
        <fieldset><legend>申请信息</legend>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">申请编号：</label>
            <div class="formControls col-xs-8 col-sm-5">
                {$info.code|default=""}
            </div>
            <div class="formControls col-xs-8 col-sm-5">
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">申请人：</label>
            <div class="formControls col-xs-8 col-sm-5">
                [{$info.apply_user_id |default=""}]   {$info.user.username|default=""} 
            </div>
            <div class="formControls col-xs-8 col-sm-5">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">申请流程：</label>
            <div class="formControls col-xs-8 col-sm-5">
                  [{$info.process_id|default=""}]    {$info.process.name|default=""} 
            </div>
            <div class="formControls col-xs-8 col-sm-5">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">当前状态：</label>
            <div class="formControls col-xs-8 col-sm-5">
                {$info.status|default=""}{$info.status_text|default=""}
            </div>
            <div class="formControls col-xs-8 col-sm-5">
            </div>
        </div>

<?php $info->attachs ;?>
{if ($info.type_id == 1 )}
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">用章次数：</label>
            <div class="formControls col-xs-8 col-sm-5">
                {$info.max_times} 次
            </div>
            <div class="formControls col-xs-8 col-sm-5">
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">用章事由：</label>
            <div class="formControls col-xs-8 col-sm-5">
                {$info.info|default=''}
            </div>
            <div class="formControls col-xs-8 col-sm-5">
            </div>
        </div>


        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">上传附件：</label>
            <div class="formControls col-xs-8 col-sm-5">

                <div class="upload-box" >
 {volist name="info.attachs|default=[]" id="vo" index="index"}    
<div class="item">
    <a href="{$vo.url}" data-lightbox="image-{$vo.id}" data-title="{$vo.title}">
        <img src="{$vo.url}" keimg="">   
    </a>
    <input type="hidden" name="attach[]" value="{$vo.id}" keattach="">
</div>
{/volist} 

                </div>

            </div>
            <div class="formControls col-xs-8 col-sm-5">

            </div>
        </div>


{else}
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">维护设备：</label>
            <div class="formControls col-xs-8 col-sm-5">
                <strong>{$info.equipment.equipment_name}</strong>
            </div>
            <div class="formControls col-xs-8 col-sm-5">
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">维护事由：</label>
            <div class="formControls col-xs-8 col-sm-5">
                {$info.info|default=''}
            </div>
            <div class="formControls col-xs-8 col-sm-5">
            </div>
        </div>

{/if}






        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">有效期：</label>
            <div class="formControls col-xs-8 col-sm-5">
                {$info.exp_time_day|default=''}天
            </div>
            <div class="formControls col-xs-8 col-sm-5">
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">过期时间：</label>
            <div class="formControls col-xs-8 col-sm-5">
                {$info.exp_time|default=''}
            </div>
            <div class="formControls col-xs-8 col-sm-5">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">创建时间：</label>
            <div class="formControls col-xs-8 col-sm-5">
                {$info.create_time|default=''}
            </div>
            <div class="formControls col-xs-8 col-sm-5">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">修改时间：</label>
            <div class="formControls col-xs-8 col-sm-5">
                {$info.update_time|default=''}
            </div>
            <div class="formControls col-xs-8 col-sm-5">
            </div>
        </div>
{if ( $info['apply_user_id'] == session('user_auth.user_id')   &&   $info['status'] >0   )}
        <div class="row cl">
            <div class="col-xs-8 col-sm-5 col-xs-offset-4 col-sm-offset-2">
                申请已提交，无法修改...
            </div>
        </div>
{else}
        <div class="row cl">
            <div class="col-xs-8 col-sm-5 col-xs-offset-4 col-sm-offset-2">
                <a class="btn btn-primary radius" href="{:url('edit')}?id={$info.id}"><i class="Hui-iconfont">&#xe632;</i> 去修改 提交申请  </a>
            </div>
        </div>
{/if}
        </fieldset>



        <fieldset><legend>流程信息</legend>
{if ($info.type_id == 1 )}
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">流程名字:</label>
            <div class="formControls col-xs-8 col-sm-5">
                {$info.process.name}
            </div>
            <div class="formControls col-xs-8 col-sm-5">
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">流程描述：</label>
            <div class="formControls col-xs-8 col-sm-5">
                {$info.process.mark}
            </div>
            <div class="formControls col-xs-8 col-sm-5">
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">印章：</label>
            <div class="formControls col-xs-8 col-sm-5">
                [{$info.process.seal.id}] {$info.process.seal.seal_name}
            </div>
            <div class="formControls col-xs-8 col-sm-5">
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">印章机名称：</label>
            <div class="formControls col-xs-8 col-sm-5">
                {$info.process.seal.equipment.equipment_name}
            </div>
            <div class="formControls col-xs-8 col-sm-5">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">印章机位置：</label>
            <div class="formControls col-xs-8 col-sm-5">
                {$info.process.seal.equipment.equipment_address}
            </div>
            <div class="formControls col-xs-8 col-sm-5">
            </div>
        </div>
{else}
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">流程名字:</label>
            <div class="formControls col-xs-8 col-sm-5">
                {$info.process.name}
            </div>
            <div class="formControls col-xs-8 col-sm-5">
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">流程描述：</label>
            <div class="formControls col-xs-8 col-sm-5">
                {$info.process.mark}
            </div>
            <div class="formControls col-xs-8 col-sm-5">
            </div>
        </div>


        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">印章机名称：</label>
            <div class="formControls col-xs-8 col-sm-5">
                {$info.process.equipment.equipment_name}
            </div>
            <div class="formControls col-xs-8 col-sm-5">
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">印章机位置：</label>
            <div class="formControls col-xs-8 col-sm-5">
                {$info.process.equipment.equipment_address}
            </div>
            <div class="formControls col-xs-8 col-sm-5">
            </div>
        </div>


{/if}
        </fieldset>

</div>

{if ($audit_user)}

    <form action="auditSave" method="post" class="form form-horizontal" id="form_audit">
        <fieldset><legend>请批示</legend>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">审核：</label>
            <div class="formControls col-xs-8 col-sm-5">
    {volist name="[1=>'通过',2=>'驳回']" id="select_name"}
                <div class="radio-box skin-minimal">
                    <label><input type="radio" name="flag" value="{$key}" {eq name="$key" value="$info['status']|default=2"}checked{/eq}>{$select_name}</label>
                </div>
    {/volist}
            </div>
            <div class="formControls col-xs-8 col-sm-5">
            </div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-2">批示：</label>
            <div class="formControls col-xs-8 col-sm-5">
                <textarea name="mark" cols="" rows="" class="textarea"  placeholder="...">{$info.address|default=''}</textarea>
            </div>
            <div class="formControls col-xs-8 col-sm-5">
            </div>
        </div>
        <div class="row cl">
            <div class="col-9 col-offset-2 ">
                <input type="hidden" name="id" value="{$audit_user.id|default=0}" />
                <input type="hidden" name="step" value="{$audit_user.step|default=0}" />
                <input type="hidden" name="user_id" value="{$audit_user.user_id|default=0}" />

                <button class="btn btn-primary radius " type="submit" >&nbsp;<i class="icon Hui-iconfont">&#xe6e1;</i> 提交&nbsp;&nbsp;
            </div>
        </div>
        </fieldset>
    </form>
{/if}

        <fieldset><legend>审核流程</legend>
{//$info['status']}    

{if ($info['status'] == 0  )}  申请提交后，才能查看审核流程哦~~~~ {/if}
{if ($info['status'] == 1  )} 申请正在审核中~~~~ {/if}
{if ($info['status'] > 1   )}   审核通过 {/if}
{if ($info['status'] == -1 )}  审核未通过，查看原因... {/if}



        <table class="table table-border table-bordered table-bg">
        <thead>
            <tr class="text-c">
                <th width="60">
                    步骤
                </th>
                <th width="100">审核人</th>
                <th width="60">审核结果</th>
                <th>批示</th>
            </tr>
        </thead>

        <tbody id="process_tbody">




{volist name=":$info->getAudits()" id="v" key='i'}

        {volist name="v" id="vv" key='ii'} 
            <tr class="text-c">
                {if ($ii==1) } <td rowspan="{:count($v)}">第<span class="step_num"> {$i} </span>步<br/>{$vv.status_text}</td>{/if}
                <td class="text-c">
                    <span title=" {$vv.place} [role_id:{$vv.role_id}] ">{$vv.user.username}<span>
                </td>
                <td class="text-c">
                    {$vv.flag_text}
                    
                </td>
                <td class="text-l">
                   <div style=" white-space:pre-wrap">{$vv.mark|default=''}</div>
                </td>

            </tr>
        {/volist}

{/volist}


        </tbody>
        </table>
        </fieldset>

        <fieldset><legend>使用记录</legend>
        <table class="table table-border table-bordered table-bg">
            <thead>
                <tr class="text-c">
                    <th width="60">
                        序号
                    </th>
                    <th >盖章前照片</th>
                    <th >盖章后照片</th>
                    <th>创建时间</th>
                </tr>
            </thead>
{volist name="info->logs" id="vo" key='i'} 
                <tr class="text-c">
                    <td>{$i}</td>
                    <td>
    <a href="{$vo.start_img}" data-lightbox="usesealimages" data-title="">
        <img src="{$vo.start_img}" style="max-width:100px;" />
    </a>
    <br/>
    盖章前
    <!-- {$vo.start_time} -->

                    </td>
                    <td>
    <a href="{$vo.end_img}" data-lightbox="usesealimages" data-title="">
        <img src="{$vo.end_img}" style="max-width:100px;" />
    </a>
    <br/>
    盖章后
    <!-- {$vo.end_time} --> 
                    </td>
                    <td>{$vo.create_time} </td>
                </tr>
{/volist}
            <tbody>

            </tbody>
        </table>
        </fieldset>


    
</div>




{/block}
//-----------------------------------------------------------------------------------------------


<!--请在下方写此页面业务相关的脚本-->
//-----------------------------------------------------------------------------------------------
{block name="script"}
<script type="text/javascript">


$(function(){
    $form_audit = $('#form_audit');
    $form_audit.on('submit',function(){

            var $form  = $(this);
            var url = $form.attr('action');
            var type = $form.attr('method') || 'post';
            var data = $form.serialize();

        layer.confirm('确认提交【审批信息】吗？<br/> 提交后，无法修改～～～',function(index){
            layer.closeAll('dialog');
            

            $.ajax({
                url: url ,
                type:type , // get post
                data: data , 
                dataType : 'html' ,
                success:function(d){
                    try{d = JSON.parse(d);}catch(err){jBox.alert( d , '查看ajax返回值');return false;}
                    if( 1 == d.code){
                        jBox.tip( d.msg , 'success');
                        setTimeout(function(){layer_close(1);},1000);
                    }else{
                        jBox.tip( d.msg , 'error');
                    }
                },
                error:function(XMLHttpRequest, textStatus, errorThrown){
                    console.log( 'ajaxError : ' + textStatus );
                },
                complete:function(){
                    setTimeout(function(){jBox.closeTip();},3000);
                }
            });

        }); 


        return false;
    });
});


//--------------------------------------------




</script>




{/block}{//---------------------------------------------------------------------------}